package cn.sxt.bus.service.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import cn.sxt.bus.domain.Goods;
import cn.sxt.bus.mapper.GoodsMapper;
import cn.sxt.bus.service.GoodsService;
import cn.sxt.bus.vo.GoodsVo;
import cn.sxt.sys.utils.DataGridView;

@Service
public class GoodsServiceImpl implements GoodsService{

	@Autowired
	private GoodsMapper goodsMapper;

	@Override
	public DataGridView queryAllGoods(GoodsVo goodsVo) {
		Page<Object> page = PageHelper.startPage(goodsVo.getPage(), goodsVo.getLimit());
		List<GoodsVo> list = goodsMapper.queryAllGoods(goodsVo);
		return new DataGridView(page.getTotal(), list);
	}

	@Override
	public List<GoodsVo> queryAllGoodsForList(GoodsVo goodsVo) {
		// TODO Auto-generated method stub
		return goodsMapper.queryAllGoods(goodsVo);
	}

	@Override
	public int deleteGoodsById(GoodsVo goodsVo) {
		// TODO Auto-generated method stub
		return goodsMapper.deleteByPrimaryKey(goodsVo.getId());
	}

	@Override
	public int addGoods(GoodsVo goodsVo) {
		// TODO Auto-generated method stub
		return goodsMapper.insert(goodsVo);
	}

	@Override
	public Goods queryGoodsById(Integer id) {
		// TODO Auto-generated method stub
		return goodsMapper.selectByPrimaryKey(id);
	}

	@Override
	public int updateGoods(GoodsVo goodsVo) {
		// TODO Auto-generated method stub
		return goodsMapper.updateByPrimaryKeySelective(goodsVo);
	}
	
}
